/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package cpasl;

import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.GridPane;

/**
 *
 * @author seanm_000
 */
public class PreferredGridPane extends GridPane {
    
    public PreferredGridPane() {
        setAlignment(Pos.CENTER);
        setHgap(15);
        setVgap(15);
        
        Label preferredLabel = new Label("What is your preferred language now?");
        final ToggleGroup preferredGroup = new ToggleGroup();
        RadioButton aslButton = new RadioButton("American Sign Language");
        aslButton.setUserData("A");
        aslButton.setToggleGroup(preferredGroup);
        aslButton.setSelected(true);
        RadioButton englishButton = new RadioButton("English");
        englishButton.setUserData("B");
        englishButton.setToggleGroup(preferredGroup);
        RadioButton spanishButton = new RadioButton("Spanish");
        spanishButton.setUserData("C");
        spanishButton.setToggleGroup(preferredGroup);
        final TextField otherTextField = new TextField();
        RadioButton manualButton = new RadioButton("Other manual / signed language");
        manualButton.setUserData("D");
        manualButton.setToggleGroup(preferredGroup);
        RadioButton oralButton = new RadioButton("Other oral / spoken language");
        oralButton.setUserData("E");
        oralButton.setToggleGroup(preferredGroup);
        
        Button nextButton = new Button();
        nextButton.setText("Next");
        nextButton.setId("next-button");
        nextButton.setOnAction(new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent event) {
                String userData = (String) ((RadioButton) preferredGroup.getSelectedToggle()).getUserData();
                CpaslManager.getInstance().setPreferredLanguage(userData);
                CpaslManager.getInstance().switchToDisplay(Groups.EXPOSURE, 0);
            }
        });
        
        add(preferredLabel, 0, 0);
        add(aslButton, 0, 1);
        add(englishButton, 0, 2);
        add(spanishButton, 0, 3);
        add(manualButton, 0, 4);
        add(oralButton, 0, 5);
        add(nextButton, 0, 6);
    }
    
}
